package com.guagua.vas.redis;

import java.util.Map;

import org.apache.log4j.Logger;

import com.guagua.vas.constants.CacheConstants;
import com.guagua.vas.redis.RedIsService;

public class RedIsHandlerImpl implements RedIsHandler {

	static Logger logger = Logger.getLogger(RedIsHandlerImpl.class.getName());
	@Override
	public Map<String, String> getGuaguaRoomMsgMap(long roomId) {
		
		return RedIsService.getJedisByKey(CacheConstants.ROOM_VERSION+roomId);
		
	}

	@Override
	public int getGuaguaRoomUserCount(long roomId) {
		int count = 0;
		try{
			Map<String, String> roomMap = RedIsService.getJedisByKey(CacheConstants.ROOM_VERSION+roomId);
			if(roomMap!=null){
				if(roomMap.get(CacheConstants.ROOM_USER_COUNT)!=null){
					count = Integer.parseInt(roomMap.get(CacheConstants.ROOM_USER_COUNT));
				}
			}
		}catch(Exception e){
			logger.error("呱呱版：根据房间id获取当前房间在线人数."+e,e);
		}
		return count;
	}
	@Override
	public String getActiveTag() {
		
		return RedIsService.getByKey(CacheConstants.ACTIVE_TAG);
		
	}

	

	@Override
	public  Map<String, String> getSuperAdmins(){
		// TODO Auto-generated method stub
		return  RedIsService.getJedisByKey(CacheConstants.SUPER_ADMIN);
	}

}
